package com.totoro.service;

import org.hibernate.Criteria;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.totoro.dao.BaseHibernateDao;
import com.totoro.dao.DepartmentDao;
import com.totoro.domain.Department;
import com.totoro.util.Page;
/**
 * 
 * @author xiang fusheng
 *
 */
/*
 * 教研室单位service
 */
@Transactional
@Service
public class DepartmentService extends BaseService<Department, Integer>{

	private static final Logger LOGGER = LoggerFactory.getLogger(DepartmentService.class);
	
	private DepartmentDao departmentDao;
	
	public DepartmentService(){
	}
	
	
	@Autowired
	@Override
	public void setBaseDao(BaseHibernateDao<Department, Integer> departmentDao) {
		this.baseDao = departmentDao;
		this.departmentDao = (DepartmentDao) departmentDao;
		LOGGER.info("初始化DepartmentDao..." + departmentDao);
		System.out.println("setBaseDao  初始化DepartmentDao..." + departmentDao);
	}
	
	//分页查询通过页号
	public Page<Department> getPagePosts(Integer pageNo,int pageSize){
		Criteria criteria = departmentDao.createCriteria();
		return departmentDao.pagedQuery(criteria, pageNo, pageSize);
	}

}
